package com.ruge.test.springMVC.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.subject.Subject;
import org.junit.Test;

/**
 * 创建人 ：爱丽丝、如歌
 * 创建时间 ：2018-07-03  21:29
 * 描述 ：
 */
public class demo01_04_02自定义Realm测试 {
    @Test
    public void test(){

        demo01_04_01自定义Realm realm = new demo01_04_01自定义Realm();
        DefaultSecurityManager securityManager = new DefaultSecurityManager();
        securityManager.setRealm(realm);
        /**
         * 主体提交认证请求
         */
        SecurityUtils.setSecurityManager(securityManager);
        Subject subject = SecurityUtils.getSubject();

        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken("13298899809", "845376854");
        subject.login(usernamePasswordToken);
    }
}
